package system.schedule;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import system.base.Warehouse;

import com.apep.gw.service.StuationAnalyse;
import com.apep.gw.service.impl.ProductStuationAnalyse;
import com.hitrust.gs.bean.GSManufactureBean;
import com.hitrust.gs.bean.GSProductBidBean;
import com.hitrust.gs.bean.GSProductTemporaryBean;
import com.hitrust.gs.bean.GSProductTemporaryMaintainBean;
import com.hitrust.gs.bean.GSProductTypeBean;
import com.hitrust.gs.bean.GSProductUpdateIsbuyBean;
import com.hitrust.gs.bean.GSProductUpdatePriceBean;
import com.hitrust.gs.business.GSManufactureProcessor;
import com.hitrust.gs.business.GSProductTiptopStockProcesser;
import com.hitrust.gs.dao.GSManufactureDAO;
import com.hitrust.gs.dao.GSProductBidDao;
import com.hitrust.gs.dao.GSProductTypeDao;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.util.date.DateUtil;
import com.hitrust.gs.vo.GSManufactureVO;
import com.hitrust.gs.vo.ProductUpdatePicTaskVO;
import com.hitrust.gs.vo.ProductUpdatePicVO;

import framework.core.ConstDefine;
import framework.core.DBConnection;
import framework.core.ObjectList;

public class ProductUpdatePicTask implements Job{

	private static boolean isRunning = false;

	public void execute(JobExecutionContext arg0) throws JobExecutionException {
		if(!isRunning){
			myRun();
		}else{
			System.out.println("-----------------------------");
		}	
	}

	private void myRun() {
		isRunning = true;
		try {
			GSProductTiptopStockProcesser ordProcesser = new GSProductTiptopStockProcesser();
			 ArrayList productList =ordProcesser.selectProductPic();
			 for (int i = 0; i < productList.size(); i++) {
				 ProductUpdatePicTaskVO vo =(ProductUpdatePicTaskVO)productList.get(i);
				 if (vo.getId() != null) {
					 ordProcesser.updateStatus(vo.getId());
				}
				 if (vo.getProduct_id() != null && vo.getPic() != null) {
					 ordProcesser.updateProductPic(vo.getProduct_id(),vo.getPic());
				}
				
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		isRunning = false;
	}
}
